#pragma ident "$Id: XY. CAO 2017-08-15 $"

/**
* @file CorrectBiasLC.hpp
* Class to correct observables with satellite upds.
* 
*/

#ifndef GPSTK_CorrectBiasLC_HPP
#define GPSTK_CorrectBiasLC_HPP

//============================================================================
//
//  Shoujian Zhang - Wuhan University. 2011, 2012
//
//============================================================================

#include <string>
#include "ProcessingClass.hpp"
#include "PhaseBiasStore.hpp"

namespace gpstk
{

   using namespace std;

      /** @addtogroup DataStructures */
      //@{

      /** This class corrects the Melbourne-Wubbena (MW) combination and 
       *  ionosphere-free (L3) phase combination observables with corresponding 
       *  satellite upds. 
       *
       * This class is meant to be used with the GNSS data structures objects
       * found in "DataStructures" class.
       *
       * A typical way to use this class follows:
       *
       * @code
       *
       *
       *   gnssRinex gRin;
       *   CorrectBiasLC corr;
       *   coor.setSatUPDFile("whu16572.upd");
       *
       *   while(rin >> gRin)
       *   {
       *      gRin >> corr;
       *   }
       *
       * @endcode
       *
       * The "CorrectBiasLC" object will visit every satellite in the
       * GNSS data structure, i.e. "gRin" and will correct the corresponding 
       * observables with the corresponding values.
       *
       * When used with the ">>" operator, this class returns the same
       * incoming data structure with the observables corrected. Be warned
       * that if a given satellite does not have the observations required,
       * it will be summarily deleted from the data structure.
       *
       */
   class CorrectBiasLC : public ProcessingClass
   {
   public:



         /// Default constructor
      CorrectBiasLC() 
         : pBiasStore(NULL)
      { setIndex(); };


         /** Common constructor
          *
          * @warning If filename is not given, this class will look for a
          * file named "PRN_GPS" in the current directory.
          */
      CorrectBiasLC( PhaseBiasStore& updStore )
         : pBiasStore(&updStore)
      { setIndex(); };


      CorrectBiasLC& setBiasStore(PhaseBiasStore& updStore)
      {
          pBiasStore = &updStore;
          return (*this);
      };


         /** Returns a satTypeValueMap object, adding the new data generated
          *  when calling this object.
          *
          * @param time      Epoch corresponding to the data.
          * @param gData     Data object holding the data.
          */
      virtual satTypeValueMap& Process( const CommonTime& time,
                                        satTypeValueMap& gData )
         noexcept(false);


         /** Returns a gnnsRinex object, adding the new data generated
          *  when calling this object.
          *
          * @param gData    Data object holding the data.
          */
      virtual gnssRinex& Process(gnssRinex& gData)
          noexcept(false)
      { Process(gData.header.epoch, gData.body); return gData; };

   
         /// Returns an index identifying this object.
      virtual int getIndex() const;


         /// Returns a string identifying this object.
      virtual std::string getClassName() const;


         /// Default deconstructor
      virtual ~CorrectBiasLC(){};


   protected:


         /// Satellite upd file
      string rinexUPDFile;

         /// Class to read satellite upds
      PhaseBiasStore* pBiasStore;
         
      
   private:

         /// Initial index assigned to this class.
      static int classIndex;

         /// Index belonging to this object.
      int index;

         /// Sets the index and increment classIndex.
      void setIndex(void)
      { index = classIndex++; };


   }; // End of class 'CorrectBiasLC'

      //@}

}  // End of namespace gpstk

#endif   // GPSTK_CorrectBiasLC_HPP

